namespace YM{
    export class Pool<T>
    {
        private readonly  pool:Queue<T> = new Queue<T>();
        
        public fetch(con:{new ():T}):T
        {
            if (this.pool.count == 0)
            {
                return new con();
            }

            return this.pool.dequeue();
        }
		
        public  recycle(t:T):void
        {
            this.pool.enqueue(t);
        }

        public  clear():void
        {
            this.pool.clear();
        }
    }
}